package mobi.yuanshen.config;


import lombok.RequiredArgsConstructor;
import mobi.yuanshen.interceptor.MyInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@RequiredArgsConstructor
public class MvcConfig implements WebMvcConfigurer {
    // 注册 Sa-Token 拦截器，打开注解式鉴权功能
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        // 注册 Sa-Token 拦截器，校验规则为 StpUtil.checkLogin() 登录校验，打开注解式鉴权功能
        registry.addInterceptor(new MyInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns(
                        "/admin/login",
                        "/admin/register",
                        "/common/getPicCode",
                        "/doc.html",
                        "/error",
                        "/webjars/**",
                        "/favicon.ico",
                        "/fileops/**", // TODO 记得删除
                        "/v3/api-docs/**");
    }

}
